﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;

namespace GtsServer.Charge.Helper
{
    public class Helper
    {
        /// <summary>
        /// 解密
        /// </summary>
        /// <returns></returns>
        public static string DesDecode(string str, string key)
        {
            byte[] strbyte = Encoding.UTF8.GetBytes(str);
            DESCryptoServiceProvider des = new DESCryptoServiceProvider();
            des.Mode = CipherMode.ECB;
            des.Key = Convert.FromBase64String(key);
            MemoryStream ms = new MemoryStream();
            CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
            cs.Write(strbyte, 0, strbyte.Length);
            cs.FlushFinalBlock();
            return Convert.ToBase64String(ms.ToArray());
        }
    }
}
